//
//  CircularDiagramShape.swift
//  SwiftUIShape
//
//  Created by 李煜 on 2024/8/1.
//

import SwiftUI
// 环形图
struct CircularDiagramShape: View {
	var body: some View {
		ZStack {
			Circle()
				.trim(from: 0, to: 0.4)
				.stroke(Color(.systemBlue), lineWidth: 80)
			Circle()
				.trim(from: 0.4, to: 0.6)
				.stroke(Color(.systemTeal), lineWidth: 80)
			Circle()
				.trim(from: 0.6, to: 0.75)
				.stroke(Color(.systemPurple), lineWidth: 80)
			Circle()
				.trim(from: 0.75, to: 1)
				.stroke(Color(.systemYellow), lineWidth: 90)
				.overlay {
					Text("25%")
						.font(.system(.title, design: .rounded))
						.fontWeight(.bold)
						.bold()
						.foregroundStyle(.white)
						.offset(x: 80, y: -100)
				}
		}
		.frame(width: 250, height: 250)
	}
}

#Preview {
	CircularDiagramShape()
}
